home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DDJMAG / DDJ9203.ZIP / DRVMONIT.ZIP / LOGMAIN.ASM < prev    next >
Assembly Source File  |  1991-11-29  |  6KB  |  144 lines

  1. ;---------------------------------------------------------------    
  2. ;Logmain - main module for device driver monitor               |
  3. ;--------------------------------------------------------------|
  4. ;Copyright 1990, 1992 ASMicro Co.                              |
  5. ;--------------------------------------------------------------|
  6. ;                                                              |
  7. ; 4/15/90                      Rick Knoblaugh                  |
  8. ;--------------------------------------------------------------|
  9. ;include files                                                 |
  10. ;---------------------------------------------------------------    
  11.                 include logequ.inc
  12.                 include logstruc.inc
  13.  
  14. code            segment public  'CODE'
  15.                 assume cs:code, ds:code, es:code
  16. ;--------------------------------------------------------------
  17. ;EXTERNALS                                                    |
  18. ;--------------------------------------------------------------
  19.                 extrn   drv_init:near
  20.                 extrn   drv_open:near  
  21.                 extrn   drv_close:near 
  22.                 extrn   drv_ioctl_in:near
  23.                 extrn   drv_ioctl_out:near
  24.                 extrn   req_header:dword
  25.                 extrn   drv_non_supt:near
  26.                 extrn   old_stack_ptr:word  
  27.                 extrn   old_stack_seg:word  
  28.                 extrn   logr_stack:word
  29.                 extrn   logr_sp:word
  30.  
  31. ;--------------------------------------------------------------
  32.                 org     0
  33.  
  34. header          dd      -1       ;ptr to next device 
  35.                 dw      0c000h   ;char device, supports IOCTL control strings
  36.                 dw      strat_routine
  37.                 dw      int_routine
  38.                 db      'DRVMONER'      ;8 char device name
  39.  
  40. ;--------------------------------------------------------------
  41. ;Call table for processing device driver requests             |
  42. ;                                                             |
  43. ;Since the device driver logger is only in the form of a      |
  44. ;device driver to allow capturing of "config.sys" time calls  |
  45. ;(such as initialization) to other device drivers, this       |
  46. ;driver itself supports very few requests.                    |
  47. ;--------------------------------------------------------------
  48.  
  49. cmd_table       label   word
  50.                 dw      drv_init        ;initialization routine
  51.                 dw      drv_non_supt    ;media check              
  52.                 dw      drv_non_supt    ;get BPB                  
  53.                 dw      drv_ioctl_in    ;IOCTL input              
  54.                 dw      drv_non_supt    ;input                    
  55.                 dw      drv_non_supt    ;nondestructive input     
  56.                 dw      drv_non_supt    ;input status             
  57.                 dw      drv_non_supt    ;input flush              
  58.                 dw      drv_non_supt    ;output (write)           
  59.                 dw      drv_non_supt    ;output (write with verify)
  60.                 dw      drv_non_supt    ;output status            
  61.                 dw      drv_non_supt    ;output flush             
  62.                 dw      drv_ioctl_out   ;IOCTL output             
  63.                 dw      drv_open        ;device open              
  64.                 dw      drv_close       ;device close             
  65.                 dw      drv_non_supt    ;removable media          
  66.                 dw      drv_non_supt    ;reserved                 
  67.                 dw      drv_non_supt    ;reserved                 
  68.                 dw      drv_non_supt    ;reserved                 
  69.                 dw      drv_non_supt    ;generic IOCTL            
  70.                 dw      drv_non_supt    ;reserved                 
  71.                 dw      drv_non_supt    ;reserved                 
  72.                 dw      drv_non_supt    ;reserved                 
  73.                 dw      drv_non_supt    ;get logical device       
  74.                 dw      drv_non_supt    ;set logical device       
  75.  
  76. ;--------------------------------------------------------------
  77.  
  78. strat_routine   proc    far 
  79.                 mov     word ptr cs:req_header, bx      ;save ptr to cmd block
  80.                 mov     word ptr cs:req_header + 2, es          
  81.                 ret
  82. strat_routine   endp        
  83.  
  84.  
  85. int_routine     proc    far
  86.                 cli
  87.                 mov     cs:old_stack_ptr, sp
  88.                 mov     cs:old_stack_seg, ss
  89.                 mov     sp, cs
  90.                 mov     ss, sp
  91.                 mov     sp, offset cs:logr_sp  
  92.                 sti
  93.  
  94.  
  95.                 cld
  96.                 push    ds  
  97.                 push    es  
  98.                 push    ax
  99.                 push    bx
  100.                 push    cx
  101.                 push    dx
  102.                 push    di
  103.                 push    si
  104.  
  105.                 lds     di, cs:req_header       ;get ptr to cmd block
  106.                 sub     bh, bh
  107.                 mov     bl, [di].req_hdr_cmd    ;get command code
  108.                 cmp     bl, MAX_CMDS            ;compare with maximum commands
  109.                 jbe     int_r100                ;if within legal range, continue
  110.  
  111.                 mov     ax, ERR_UNKNOWN         ;get unknown command status
  112.                 jmp     short int_r300          ;go return it
  113.  
  114. int_r100:
  115.                 shl     bx, 1                   ;index into table 
  116.                 push    cs
  117.                 pop     ds                      ;get ds = cs
  118.  
  119.                 call    word ptr [bx + cmd_table] ;call processing routine
  120.  
  121.  
  122. int_r300:
  123.                 lds     di, cs:req_header       ;get ptr to cmd block
  124.                 mov     [di].req_hdr_status, ax ;return status   
  125.  
  126.                 pop     si
  127.                 pop     di
  128.                 pop     dx
  129.                 pop     cx
  130.                 pop     bx
  131.                 pop     ax
  132.                 pop     es
  133.                 pop     ds
  134.  
  135.                 cli
  136.                 mov     sp, cs:old_stack_ptr
  137.                 mov     ss, cs:old_stack_seg
  138.                 sti
  139.                 ret
  140. int_routine     endp       
  141.  
  142. code            ends
  143.                 end
  144.